using System;
using Microsoft.SPOT;
using System.IO;

namespace Netduino4Fun.Framework.Log
{
    public class MemoryAppender : IAppender
    {
        MemoryStream stream;
        StreamWriter writer;

        public MemoryAppender()
        {
            stream = new MemoryStream();
            writer = new StreamWriter(stream);
        }

        public void Write(string message)
        {
            writer.WriteLine(message);
        }

        public string Dump()
        {
            stream.Seek(0, SeekOrigin.Begin);

            StreamReader reader = new StreamReader(this.stream);
            string dump = reader.ReadToEnd();

            return dump;
        }
    }
}
